<?php

namespace Home\Controller;

use Think\Controller;

class PostController extends Controller{

    public function index(){
        //头部banner
        $this->banner = getBanner();

        $where = array();
        $this->postList = M('post')->where($where)->select();

        $post    = M('post'); // 实例化User对象
        $where['status']      = array('gt',-1);

        $count      = $post->where($where)->count();// 查询满足要求的总记录数
        $Page       = new \Think\Page($count,3);// 实例化分页类 传入总记录数和每页显示的记录数(25)
        $this->page = $Page->show();// 分页显示输出
        $this->postList = $post->where($where)->order(array('id' => 'desc'))->limit($Page->firstRow.','.$Page->listRows)->select();

        $this->display();
    }

    public function detail($id){
        //头部banner
        $this->banner = getBanner();

        //查询详情
        $this->info = M('post')->find($id);

        $this->display(); // 输出模板
    }
}
